package com.cloudwise.service.impl;

import com.cloudwise.dao.TblGoodDao;
import com.cloudwise.entity.TblGood;
import com.cloudwise.service.TblGoodService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品表(TblGood)表服务实现类
 *
 * @author
 * @since 2022-03-14 16:18:44
 */
@Service("tblGoodService")
public class TblGoodServiceImpl implements TblGoodService {
    @Resource
    private TblGoodDao tblGoodDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TblGood queryById(Integer id) {
        return this.tblGoodDao.queryById(id);
    }

    @Override
    public List<TblGood> findAllGoods() {
        return tblGoodDao.findAllGoods();
    }


    /**
     * 新增数据
     *
     * @param tblGood 实例对象
     * @return 实例对象
     */
    @Override
    public TblGood insert(TblGood tblGood) {
        this.tblGoodDao.insert(tblGood);
        return tblGood;
    }

    /**
     * 修改数据
     *
     * @param tblGood 实例对象
     * @return 实例对象
     */
    @Override
    public TblGood update(TblGood tblGood) {
        this.tblGoodDao.update(tblGood);
        return this.queryById(tblGood.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.tblGoodDao.deleteById(id) > 0;
    }
}
